package com.jhmk.jhecis.controller;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jhmk.jhecis.domain.DeptDict;
import com.jhmk.jhecis.domain.common.PageVm;
import com.jhmk.jhecis.domain.common.R;
import com.jhmk.jhecis.service.DeptDictService;
import io.micrometer.common.util.StringUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequiredArgsConstructor
@Tag(name = "科室字典接口",description = "科室字典接口")
public class DeptController {

    final DeptDictService dictService;

    @PostMapping("getDeptPageList")
    @Operation(description = "获取科室字典分页数据" )
    public R<IPage<DeptDict>> getDeptPageList(@RequestBody PageVm<String> req)
    {
        Page<DeptDict> page=new Page<>(req.getPageNo(),req.getPageSize());
        QueryWrapper<DeptDict> queryWrapper = new QueryWrapper<>();
        //获取门诊科室
        queryWrapper.lambda().eq(DeptDict::getOutpOrInp,1);

        //搜索内容
        if(StrUtil.isNotEmpty(req.getSearch()))
        {
            queryWrapper.lambda().like(DeptDict::getDeptName,req.getSearch());
        }
        IPage<DeptDict> res=  dictService.page(page,queryWrapper);
        return  R.ok(res);
    }
}
